import {storeBindingsBehavior } from 'mobx-miniprogram-bindings'
import{store} from '../store/store'
Component({
  options: {
    styleIsolation: 'shared'
  },
  //方法映射
  behaviors:[storeBindingsBehavior],
  storeBindings: {
    store,
    // 映射数据
    fields: {
    active:'activeTabBarIndex'
    },
    //获取方法
    actions : {
      updateActive :'updateActiveTabBarIndex'
    }
  },
  
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    "list":[{
      "pagePath": "/pages/home/home",
      "text": "首页",
      "iconPath": "/images/tabs/home.png",
      "selectedIconPath": "/images/tabs/home-active.png"
    },{
      "pagePath": "/pages/my/my",
      "text":"我的",
      "iconPath": "/images/tabs/my.png",
      "selectedIconPath": "/images/tabs/my-active.png"
    }]
  },
 
  /**
   * 组件的方法列表
   */
  methods: {
    onChange(event) {
      // event.detail 的值为当前选中项的索引
      // this.setData({ active: event.detail });
      this.updateActive(event.detail)
      wx.switchTab({
        url: this.data.list[event.detail].pagePath,
      })
    },
  }
})
